package cn.glutnn.subject.infra.rpc;

import cn.glutnn.auth.application.api.UserFeignService;
import cn.glutnn.auth.application.entity.AuthUserDTO;
import cn.glutnn.auth.application.entity.Result;
import cn.glutnn.subject.infra.entity.UserInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

/**
 * Author:   msh
 * Date:     2025/1/23 上午1:21
 * Description:
 */

@Component
public class UserRpc {

    @Resource
    private UserFeignService userFeignService;

    public UserInfo getUserInfo(String userName) {
        AuthUserDTO authUserDTO = new AuthUserDTO();
        authUserDTO.setUserName(userName);
        Result<AuthUserDTO> result = userFeignService.getUserInfo(authUserDTO);
        UserInfo userInfo = new UserInfo();
        if (!result.getSuccess()) {
            return userInfo;
        }
        AuthUserDTO data = result.getData();
        userInfo.setUserName(data.getUserName());
        userInfo.setNickName(data.getNickName());
        userInfo.setAvatar(data.getAvatar());
        return userInfo;
    }

}

